package com.malamute.system.service.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.malamute.system.dao.TreeNodeDao;
import com.malamute.system.entity.TreeNode;
import com.malamute.system.service.TreeService;

@Service
public class TreeServiceImpl implements TreeService {
	@Autowired
	private TreeNodeDao treeNodeDao;

	@Override
	public List<TreeNode> listFoldensTree() {
		DetachedCriteria criteria = DetachedCriteria.forClass(TreeNode.class);
		criteria.add(Restrictions.eq("isLeaf", false));
		return treeNodeDao.findByCriteria(criteria);
	}

	@Override
	public List<TreeNode> listTree() {
		DetachedCriteria criteria = DetachedCriteria.forClass(TreeNode.class);
		return treeNodeDao.findByCriteria(criteria);
	}

}
